<?php
require_once('header.php');

if(isset($_POST['u']))
{
	$_u = makesafe($_POST['u']);
	if(empty($_u) || !__User::validateUsername($_u))
	{
		echo json_encode(array('error' => 1, 'msg' => "Invalid or empty username"));
		return;
	}
	
    if(!__User::usernameExists($_u))
  	    echo json_encode(array('success' => 1, 'msg' => "Username is available"));
    else	
		echo json_encode(array('error' => 1, 'msg' => "Username is already taken"));
}
return;

?>